/**
 * Filename: ReqUtils.java
 *
 * @author Firefly
 * @contact postfirefly@163.com
 * @time 2016/3/1 10:27
 */
package com.github.postsanf.yinian.utils;

import java.util.List;

/**
 * 请求工具类
 */
public class ReqUtils {

    /**
     * 判断是否访问成功
     */
    public static Boolean isSuccess(String str) {
        if ("0".equals(str) || "0" == str) {
            return true;
        }
        return false;
    }

    public static Boolean isNewUser(String str) {
        if ("2003".equals(str) || "2003" == str) {
            return true;
        }
        return false;
    }

    public static Boolean is1027(String str) {
        if ("1027".equals(str) || "1027" == str) {
            return true;
        }
        return false;
    }


    public static Boolean isSuccessTwo(String str) {
        if ("2000".equals(str) || "2000" == str) {
            return true;
        }
        return false;
    }

    /**
     * 性别跳整
     */
    public static String sexIsInt(String val, Boolean flag) {
        if (flag) {
            return Integer.parseInt(val) == 0 ? "女" : "男";
        }
        return "女".equals(val) ? "0" : "1";
    }

    //图片数据处理成字符串
    public static String list2String(List<String> datas) {
        String result = "";
        for (int i = 0; i < datas.size(); i++) {
            result += (i + 1 == datas.size()) ? datas.get(i) : datas.get(i) + ",";
        }
        return result;
    }
}